<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model as Info;

use App\Http\Controllers\Controller as C;

class Model extends Info
{
    public function scopeType($query, $type)
    {
        $typeId = C::typeToId($type);
        return $query->where('type', $typeId);
    }

    public function scopeIsShow($query, $is_show=1)
    {
        return $query->where('is_show', $is_show);
    }

    public function scopeGetShowIndex($query, $type, $take=10)
    {
        return $query->Type($type)->IsShow()->where('is_show_index', 1)->latest('number')->take($take);
    }
}
